﻿using System.Collections;
using System.Diagnostics.Contracts;

namespace CodePlex.Diagnostics.Contracts.Conditions
{
	public static partial class Condition
	{
    [Pure]
    public static bool IsEmpty<T>(this ICollection collection)
    {
      Contract.Requires(!collection.IsNull());
      Contract.Ensures(Contract.Result<bool>() == (collection.Count == 0));

      return collection.Count == 0;
    }

    [Pure]
    public static bool IsNullOrEmpty<T>(this ICollection collection)
    {
      Contract.Ensures(Contract.Result<bool>() == (collection.IsNull() || collection.IsEmpty<ICollection>()));

      return collection.IsNull() || collection.IsEmpty<ICollection>();
    }
	}
}
